package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection c1 = new HashSet();
        c1.add("java");
        c1.add("c++");
        c1.add("python");
        System.out.println("c1:" + c1);

        Collection c2 = new ArrayList();
        c2.add("android");
        c2.add("ios");
        c2.add("linux");
        c2.add("c++");
        System.out.println("c2:" + c2);

        c1.addAll(c2);
        System.out.println("c1:" + c1);
        System.out.println("c2:" + c2);
        /*
            boolean addAll(Collection c)
            将参数指定的集合中所有的元素添加到集合当中去
         */
        Collection c3 = new ArrayList();
        c3.add("c++");
        c3.add("python");
        c3.add("linux");
        System.out.println("c3:" + c3);
        Boolean contains = c1.containsAll(c3);
        System.out.println(contains);

        //c1.retainAll(c3);//保留C1中和C3一样的元素
        c1.removeAll(c3);//删除c1中与c3一样的元素
        System.out.println("c1:" + c1);
        System.out.println("c3:" + c3);
    }
}
